#ifndef __IM_BYTE_STREAM_H__
#define __IM_BYTE_STREAM_H__

#include <stdio.h>
#include <im_base_types.h>
#include <im_stream.h>
#include <im_memory_chunk.h>

/**
 * @defgroup IMByteStream
 * @ingroup PrivateIMBus
 * @{
 */

/** @struct IMByteStream
 *  @brief It's an IMStream implementation based on a simple byte protocol.
 */

IM_BEGIN_DECLS

#define IM_BYTE_STREAM(p)           (IM_TYPE_INSTANCE_CHECK_CAST((p),IM_TYPE_BYTE_STREAM,IMByteStream))
#define IM_CONST_BYTE_STREAM(p)     (IM_TYPE_INSTANCE_CHECK_CAST_CONST((p),IM_TYPE_BYTE_STREAM,IMByteStream))
#define IM_BYTE_STREAM_CLASS(c)     (IM_TYPE_CLASS_CHECK_CAST((c),IM_TYPE_BYTE_STREAM,IMByteStreamClass))
#define IM_IS_BYTE_STREAM(p)        (IM_TYPE_INSTANCE_CHECK_TYPE((p),IM_TYPE_BYTE_STREAM))
#define IM_IS_BYTE_STREAM_CLASS(c)  (IM_TYPE_CLASS_CHECK_TYPE((c),IM_TYPE_BYTE_STREAM))
#define IM_BYTE_STREAM_GET_CLASS(p) (IM_TYPE_INSTANCE_GET_CLASS_CAST((p),IM_TYPE_BYTE_STREAM,IMByteStreamClass))

typedef struct _IMByteStream         IMByteStream;
typedef struct _IMByteStreamClass    IMByteStreamClass;

/**
 * @brief Create a new IMByteStream object.
 */
IMStream*       im_byte_stream_new              ();

/**
 * @brief Set the memory chunk object for retrieving and storing
 *        data.
 */
void            im_byte_stream_set_memory_chunk (IMByteStream           *stream,
                                                 IMMemoryChunk          *chunk);

/**
 * @brief Get the memory chunk object used by this byte stream object for
 *        retrieving and storing data.
 *
 * @return the memory chunk currently used by the byte stream object,
 *         it shouldn't be changed or released.
 */
IMMemoryChunk*  im_byte_stream_get_memory_chunk (const IMByteStream     *stream);

/**
 * @brief Get a copy of the memory chunk object used by this byte stream
 *        object for retrieving and storing data.
 *
 * @return a copy of the memory chunk currently used by the byte stream object,
 *         it should be released afterwards.
 */
IMMemoryChunk*  im_byte_stream_dup_memory_chunk (const IMByteStream     *stream);

IM_END_DECLS

#endif
/**  @} */

/*
vi:ts=4:nowrap:ai:expandtab
*/
